<template>
  <div>
    <!-- 顶部 -->
    <nav-bar title="结果111" />
    <!-- 主要内容 -->
    <div class="mian-wrapper">
      <div
        v-for="(item, i) in newData"
        :key="i"
        class="mian-content"
      >
        <!-- 左边的内容 -->
        <div class="content">
          <div class="title">
            {{ item.title }}
          </div>
          <div>
            <span class="sty">
              赞同 {{ item.likeCount > strNumMax ? `${strNumMax}+` : item.likeCount }}
            </span>
            <span class="sty">
              评论 {{ item.commentCount > commentNumMax ? `${commentNumMax}+` : item.commentCount }}
            </span>
            <span class="sty">{{ item.time }}</span>
          </div>
        </div>
        <!-- 右边图片 -->
        <div class="img">
          <img :src="item.thumbSrc">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import moment from 'moment';

export default {
  // components: { navBar },
  name: 'QaPage',
  data() {
    return {
      data: new Array(100)
        .fill(0)
        .map(() => ({
          // 标题
          title: '作为IT行业的过来人，你有什么话相对后辈说的？？？？？？？？？',
          // 点赞数 超过999显示为999+
          likeCount: 1234,
          // 评论数 超过999显示为999+
          commentCount: 555,
          // 发布时间
          pubTimestamp: 1658482134742,
          // 缩略图
          thumbSrc: 'https://pic1.zhimg.com/80/v2-8e77b2771314f674cccba5581560d333_xl.jpg?source=4e949a73',
        })),
      strNumMax: '999',
      commentNumMax: '99',
    };
  },
  computed: {
    newData() {
      return this.data.map(d => ({
        ...d,
        time: moment(d.pubTimestamp).fromNow()
      }))
    },
  },
  methods: {
    goBack() {
      // 回到上一页
      this.$router.go(-1);
    },
  }
}
</script>

<style lang="less" scoped>
// body {
//   overflow:-Scroll;overflow-y:hidden;
// }

// 主要内容
.mian-wrapper {
  padding: 0 16px;
  overflow: auto;
  height: calc(100% - 46px);
}
.mian-content {
  display: flex;
  width: 100%;
  border-bottom: 1px solid #eee;
  box-sizing: border-box;
  justify-content: space-between;
  padding: 30px 0;

  // 右边图片
  .img {
    width: 124px;
    height: 100%;

    img{
    width: 100%;
    height: 100%;
    border-radius: 4px;
    }
  }
  //左边的内容
  .content{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    margin-right: 30px;

    .title {
    width: 100%;
    // 有限的空间才能有溢出的可能
    overflow: hidden;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    margin-bottom: 10px;
    color: #3a3c3a;
    word-break: break-all;
    line-break: anywhere;
    }

    .sty {
      font-size: 12px;
      color: #aaa;
      margin-right: 5px;
    }
  }

}
</style>
